import random
import numpy as np
def getHash(v,x,b,w):
    return (v.dot(x)+b)//w            #dot:向量的积
def dealOneBuket(dataSet):
    dataSet=np.array(dataSet)
    k = dataSet.shape[1]    #数组维度中的列个数：6
    b = random.uniform(0,w) #在[0,w]中随机生成一个实数
    x=np.random.random(k)     #生产k个[0,1)的数
    buket=[]
    for data in dataSet:
        h=getHash(data,x,b,w)
        buket.append(h)
    return buket
def deaMoreBuket(dataSet,n):
    for _ in range(n):
        print(dealOneBuket(dataSet))
dataSet=[[8,7,6,4,8,9], [7,8,5,8,9,7], [3,2,0,1,2,3], [3,3,2,3,3,3], [21,21,22,99,2,12],[1,1,1,0,1,0]]
dataSet=np.array(dataSet)
w=4
n=6
deaMoreBuket(dataSet,n)